package main

import (
	"fmt"
	"net/http"
	"os"
	"wdc/atm"
	"wdc/bmi"
	"wdc/containers"
	database "wdc/databaas"
	"wdc/jiuba"
	"wdc/shuxue"
	"wdc/student"
)

func main() {

	for i := 0; i < 3; i++ {
		if database.Login() {
			goto amHere
		} else {
			fmt.Println("可以登录3次   失败了", i+1, "次")
			if i == 2 {
				fmt.Println("你已经尝试3次,为了系统安全。禁止尝试")
				return
			}
		}
	}
amHere:
	for i := 0; i < 3; i++ {
		fmt.Println("-----------------------")
		var comand string

		fmt.Println("zgzl 命令用来修改个人资料")
		fmt.Println(" jiafen  命令用来加分")

		if len(os.Args) > 1 {
			comand = os.Args[1]
		} else {
			fmt.Println("输入模块名字")
			fmt.Println("支持bmi,add,jianfa, chufa,chenfa,array,")
			fmt.Println("支持slice,jiuba,map,object,oob,api,db,xgwj,xgml")
			fmt.Println("支持claas2,xgmm,xgzl,jiafen,tj,zhuanzhang,qqemail ")
			fmt.Scanln(&comand)
		}

		switch comand {
		case "bmi":
			bmi.BMI()
		case "add":
			shuxue.Add()
		case "jianfa":
			shuxue.Jianfa()
		case "chufa":
			shuxue.ChuFaDemo()
		case "chenfa":
			shuxue.Chengfa()
		case "array":
			containers.Suili()
		case "slice":
			containers.InserStudents()
		case "jiuba":
			jiuba.Jiuba()
		case "map":
			containers.QueryLuquxian()
		case "object":
			atm.ObjectDemo()
		case "oob":
			student.OOBDemo()
		case "db":
			database.DBEmo()
		case "xgmm":
			database.ResetPswd()
		case "xgzl":
			database.ModifyMyInfo()
		case "jiafen":
			database.Jiafen()
		case "tj":
			database.AddStudent()
		case "zhuanzhang":
			database.Zhuanzhang()
		case "class2":
			student.SaveStudentRecords()
		case "xgwj":
			student.ReadFile()
		case "dkml":
			student.OpenDir()

		case "api":
			fmt.Println("服务器启动了")
			http.HandleFunc("/api/bmi ", bmi.BmiApt)
			http.ListenAndServe(":999", nil)
			break amHere
		}

	}

}
